#include "yocto/utest/run.hpp"

#include "core/verlet.hpp"
#include "core/fcc.hpp"
#include "yocto/wtime.hpp"

using namespace FastMD;


YOCTO_UNIT_TEST_IMPL(steps)
{
	std::cerr << "Testing Verlet Speed" << std::endl;
	const size_t niter = 1000;
	const size_t m     = 13;
	const U3D    cr(m,m,m);
	const size_t np    = 4 * cr.items();
	const Real   L     = __pow( np, __ONE/__THREE );
	Verlet       step(0.1);
	Frame        F(step.vectors(),np);
	const bool   isothermal = false;
	F.set_box( V3D(L,L,L) );
	double       tmx = 0;
	
	FCC::Build( F[0], cr, F.box, F.ibox, 0 );
	
	wtime  chrono;
	for( size_t iter=0; iter < niter; ++iter )
	{
		for( size_t i=0; i <np; ++i ) F[ Frame::ACCELERATIONS ][i].rand(1);
		chrono.start();
		step.predict(F);
		step.correct(F,isothermal);
		tmx += chrono.query();
	}
	tmx /= niter;
	std::cerr << "time= " << tmx*1000.0 << " ms" << std::endl;
	
}
YOCTO_UNIT_TEST_DONE()
